package com.erp.controller;

import com.erp.common.core.controller.BaseController;
import com.erp.common.core.page.TableDataInfo;
import com.erp.domain.ErpOutboundAudit;
import com.erp.domain.ErpProductVO;
import com.erp.domain.OutboundAuditVO;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:lxs
 * @CreateTime: 2025-09-05
 * @Description:出库审核控制层
 */
@RestController
@RequestMapping("/erp/audit/outbound")
@Slf4j
public class ErpOutboundAuditController extends BaseController {
    @Autowired
    private com.erp.service.IErpOutboundAuditService erpOutboundAuditService;
    @GetMapping("/list")
    public TableDataInfo list(ErpOutboundAudit erpOutboundAudit) {
        log.info("出库审核列表查询 >>> 请求到达Controller"); // 新增日志
        log.info("请求参数: {}", erpOutboundAudit); // 打印完整参数
        try {
            PageHelper.startPage(1, 10);
            List<OutboundAuditVO> list = erpOutboundAuditService.list(erpOutboundAudit);
            log.info("查询结果条数: {}", list.size());
            return getDataTable(list);
        } catch (Exception e) {
            log.error("出库审核查询异常:", e); // 捕获异常
            throw e;
        }
    }
    //更新审核状态
    @RequestMapping("/update")
    public int updateAudit(@RequestBody OutboundAuditVO outboundAuditVO) {
        log.info("更新审核状态 >>> 请求到达Controller"); // 新增日志
        log.info("请求参数: {}", outboundAuditVO); // 打印完整参数
        return erpOutboundAuditService.updateAudit(outboundAuditVO);
    }
    //查询产品列表
    @RequestMapping("/product")
    public TableDataInfo getListProduct(@RequestParam String outboundNo) {
        log.info("查询出库产品数据 >>> 请求到达Controller"); // 新增日志
        log.info("请求参数: {}", outboundNo); // 打印完整参数
        List<ErpProductVO> list = erpOutboundAuditService.getListProduct(outboundNo);
        return getDataTable(list);
    }
}
